<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="从零开始的算法历险 – 0x011. 从两数之和(2-Sum)开始1.1 问题描述给定一个整数数组 nums 和一个目标值 target，请你在该数组中找出和为目标值的那 两个 整数，并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是，数组中同一个元素不能使用两遍。 示例: 给定 nums &#x3D; [2, 7, 11, 15], target &#x3D; 9 因为 nums[0] + nums[">
<meta property="og:type" content="article">
<meta property="og:title" content="X个数之和系列问题">
<meta property="og:url" content="http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/index.html">
<meta property="og:site_name" content="传火之人">
<meta property="og:description" content="从零开始的算法历险 – 0x011. 从两数之和(2-Sum)开始1.1 问题描述给定一个整数数组 nums 和一个目标值 target，请你在该数组中找出和为目标值的那 两个 整数，并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是，数组中同一个元素不能使用两遍。 示例: 给定 nums &#x3D; [2, 7, 11, 15], target &#x3D; 9 因为 nums[0] + nums[">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-07-29T07:28:45.000Z">
<meta property="article:modified_time" content="2020-08-05T01:45:24.898Z">
<meta property="article:author" content="Arthur Blitz">
<meta property="article:tag" content="Algorithm">
<meta property="article:tag" content="CPP">
<meta name="twitter:card" content="summary">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>X个数之和系列问题</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
      
<link rel="stylesheet" href="/css/rtl.css">

    
    <!-- rss -->
    
    
<meta name="generator" content="Hexo 4.2.1"></head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects/">Projects</a></li>
         
          <li><a href="/typescript/">typescript</a></li>
         
          <li><a href="/flex-bison/">flex-bison</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/2020/07/29/From-0-to-1-Graphviz/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="/2020/07/29/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84Dot%E5%8F%AF%E8%A7%86%E5%8C%96%E5%8E%86%E9%99%A9/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&text=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&is_video=false&description=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=X个数之和系列问题&body=Check out this article: http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&name=X个数之和系列问题&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&t=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#从零开始的算法历险-–-0x01"><span class="toc-number">1.</span> <span class="toc-text">从零开始的算法历险 – 0x01</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-从两数之和-2-Sum-开始"><span class="toc-number">1.1.</span> <span class="toc-text">1. 从两数之和(2-Sum)开始</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-问题描述"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.1 问题描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-问题分析"><span class="toc-number">1.1.2.</span> <span class="toc-text">1.2 问题分析</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-实现代码"><span class="toc-number">1.1.3.</span> <span class="toc-text">1.3 实现代码</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        X个数之和系列问题
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">传火之人</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2020-07-29T07:28:45.000Z" itemprop="datePublished">2020-07-29</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/Leetcode-Quiz/">Leetcode & Quiz</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/Algorithm/" rel="tag">Algorithm</a>, <a class="tag-link" href="/tags/CPP/" rel="tag">CPP</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h1 id="从零开始的算法历险-–-0x01"><a href="#从零开始的算法历险-–-0x01" class="headerlink" title="从零开始的算法历险 – 0x01"></a>从零开始的算法历险 – 0x01</h1><h2 id="1-从两数之和-2-Sum-开始"><a href="#1-从两数之和-2-Sum-开始" class="headerlink" title="1. 从两数之和(2-Sum)开始"></a>1. 从两数之和(2-Sum)开始</h2><h3 id="1-1-问题描述"><a href="#1-1-问题描述" class="headerlink" title="1.1 问题描述"></a>1.1 问题描述</h3><blockquote><p>给定一个整数数组 nums 和一个目标值 target，请你在该数组中找出和为目标值的那 两个 整数，并返回他们的数组下标。</p>
<p>你可以假设每种输入只会对应一个答案。但是，数组中同一个元素不能使用两遍。</p>
<p>示例:</p>
<p>给定 nums = [2, 7, 11, 15], target = 9</p>
<p>因为 nums[0] + nums[1] = 2 + 7 = 9<br>所以返回 [0, 1]</p>
<footer><strong>@Leetcode-cn</strong><cite><a href="https://leetcode-cn.com/problems/two-sum/description/" target="_blank" rel="noopener">leetcode-cn.com/problems/two-sum/description</a></cite></footer></blockquote>

<h3 id="1-2-问题分析"><a href="#1-2-问题分析" class="headerlink" title="1.2 问题分析"></a>1.2 问题分析</h3><h3 id="1-3-实现代码"><a href="#1-3-实现代码" class="headerlink" title="1.3 实现代码"></a>1.3 实现代码</h3><figure class="highlight cpp"><figcaption><span>twosum.cpp</span><a href="/downloads/code/twosum.cpp">view raw</a></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; <span class="title">twoSum</span><span class="params">(<span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt;&amp; numbers,<span class="keyword">int</span> targets)</span></span>{</span><br><span class="line">    <span class="built_in">map</span>&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; mapping;</span><br><span class="line">    <span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; result;</span><br><span class="line">    <span class="comment">// Map&lt;Value, Index&gt;</span></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>;i &lt; numbers.size();i++){</span><br><span class="line">        mapping[numbers[i]] = i;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; numbers.size();i++){</span><br><span class="line">        <span class="keyword">int</span> searched = targets - numbers[i];</span><br><span class="line">        <span class="keyword">if</span>(mapping.find(searched) != mapping.end() &amp;&amp; i != mapping[searched]){</span><br><span class="line">            result.push_back(i+<span class="number">1</span>);</span><br><span class="line">            result.push_back(mapping[searched] + <span class="number">1</span>);</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        }</span><br><span class="line">    }</span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
  </div>
</article>



        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects/">Projects</a></li>
         
          <li><a href="/typescript/">typescript</a></li>
         
          <li><a href="/flex-bison/">flex-bison</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#从零开始的算法历险-–-0x01"><span class="toc-number">1.</span> <span class="toc-text">从零开始的算法历险 – 0x01</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-从两数之和-2-Sum-开始"><span class="toc-number">1.1.</span> <span class="toc-text">1. 从两数之和(2-Sum)开始</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-问题描述"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.1 问题描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-问题分析"><span class="toc-number">1.1.2.</span> <span class="toc-text">1.2 问题分析</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-实现代码"><span class="toc-number">1.1.3.</span> <span class="toc-text">1.3 实现代码</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&text=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&is_video=false&description=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=X个数之和系列问题&body=Check out this article: http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&title=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&name=X个数之和系列问题&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://whtoo.github.io/2020/07/29/X%E4%B8%AA%E6%95%B0%E4%B9%8B%E5%92%8C%E7%B3%BB%E5%88%97%E9%97%AE%E9%A2%98/&t=X个数之和系列问题" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy;
    
    
    2016-2020
    Arthur Blitz
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects/">Projects</a></li>
         
          <li><a href="/typescript/">typescript</a></li>
         
          <li><a href="/flex-bison/">flex-bison</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->

<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">


<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">


    <!-- jquery -->

<script src="/lib/jquery/jquery.min.js"></script>


<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>

<!-- clipboard -->

  
<script src="/lib/clipboard/clipboard.min.js"></script>

  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Disqus Comments -->


  <script src='https://cdnjs.cloudflare.com/ajax/libs/viz.js/1.7.1/viz.js'></script>
  <script>
    String.prototype.replaceAll = function(search, replacement) {
      var target = this;
      return target.split(search).join(replacement);
    };

    let vizObjects = document.querySelectorAll('.graphviz')

    for (let item of vizObjects) {
      let svg = undefined
      try {
        svg = Viz(item.textContent.replaceAll('–', '--'), 'svg')
      } catch(e) {
        svg = `<pre class="error">${e}</pre>`
      }
      item.outerHTML = svg
    }
  </script>

</body>
</html>
